package com.zlp.mall.portal.security.dto;

import com.zlp.mall.portal.modules.ums.model.Member;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;

/***
 *
 * 用户信息、用户权限信息
 */
public class MemberDetails implements UserDetails {

    // 用户信息
    private Member member;

    public MemberDetails(Member member) {
        this.member = member;
    }


    /**
     * 前台除了白名单 没有其他的权限资源
     * @return
     */
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {

        return null;
    }

    @Override
    public String getPassword() {
        return member.getPassword();
    }

    @Override
    public String getUsername() {
        return member.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return false;
    }

    @Override
    public boolean isAccountNonLocked() {
        return false;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return false;
    }

    /**
     * 用户是否启用状态
     * @return
     */
    @Override
    public boolean isEnabled() {
        return member.getStatus()==1;
    }


    public Member getUmsMember() {
        return member;
    }
}
